package com.istar.framework.service.implement;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.istar.framework.dao.interfaces.ICommonDao;
import com.istar.framework.service.interfaces.ICommonService;

@Service
public abstract class CommonServiceImpl<T> implements ICommonService<T> {

	abstract ICommonDao<T> getDao();

	@Transactional
	public List<T> getAll() {
		return getDao().listAll();
	}

	@Transactional
	public T getById(int id) {
		return getDao().get(id);
	}

	@Transactional
	public boolean add(T entity) {
		return getDao().insert(entity);
	}

	@Transactional
	public boolean delete(int id) {
		return getDao().delete(id);
	}

	@Transactional
	public boolean update(T entity) {
		return getDao().update(entity);
	}

}
